package com.si3.controlador;

import java.beans.PropertyEditorSupport;

import com.si3.jpa.ControlJPA;
import com.si3.modelo.Centro;


public class CentroEditorSupport extends PropertyEditorSupport {

        
    
 
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        setValue(ControlJPA.getInstancia().getEntidad(Integer.parseInt(text),Centro.class));
    }
 
    @Override
    public String getAsText() {
        Centro centro = (Centro) getValue();
        if (centro == null) {
            return null;
        } else {
            return new Integer(centro.getCodigo()).toString();
        }
    }
}


